package com.eastfair.projectcore.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 字典表
 * </p>
 *
 * @author ligang
 * @date 2021-07-09
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "DictTypeCodeEnum", description = "字典类型 	#DictTypeCodeEnum{menu:菜单;industry:特定行业;common:公共行业;exhibitoraccounttype:展商账号类型-枚举")
public enum DictTypeCodeEnum implements BaseEnum {

    /**
     * MENU="菜单"
     */
    MENU("菜单"),
    /**
     * INDUSTRY="特定行业"
     */
    INDUSTRY("特定行业"),
    /**
     * COMMON="公共行业"
     */
    COMMON("公共行业"),
    /**
     * EXHIBITORACCOUNTTYPE="展商账号类型"
     */
    EXHIBITORACCOUNTTYPE("展商账号类型"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static DictTypeCodeEnum match(String val, DictTypeCodeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static DictTypeCodeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(DictTypeCodeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "MENU,INDUSTRY,COMMON,EXHIBITORACCOUNTTYPE", example = "MENU")
    public String getCode() {
        return this.name();
    }

}
